const router = require('koa-router')()

router.prefix('/demo')

router.get('/', async (ctx, next) => {
  ctx.body = await ctx.ajax({ url: 'user:update' })
})

router.get('/all', async (ctx, next) => {
  ctx.body = await ctx.ajax.all({
    update: { url: 'user:update' },
    list: { url: 'user:list' },
  })
})

router.get('/string', async (ctx, next) => {
  console.log(1)
  await next()
  console.log(4)
})

router.get('/string*', async (ctx, next) => {
  console.log(2)
  await next()
  console.log(3)
})

module.exports = router
